package com.ruoyi.project.storage.controller;

import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.common.enums.TerminalEnum;
import com.ruoyi.project.storage.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 首页修改密码Controller
 *
 * @author mengyuanqing
 * @date 2020/5/6
 */
@RestController
@RequestMapping("backend/home")
@Api(tags = {"【后台端】5.3.1 首页"},description = "修改密码")
public class BackendHomeController extends BaseController {
    // 通过注释注入用户Service
    @Autowired
    private IUserService userService;
    /**
     * 修改密码
     */
    @Log(title = "5.3.1.1 修改密码", businessType = BusinessType.UPDATE)
    @PutMapping("/updatePassword/{oldPassword}/{newPassword}")
    @ApiOperation(value = "5.3.1.1 修改密码", notes = "修改密码")
    public AjaxResult updatePwd(@PathVariable String oldPassword,@PathVariable String newPassword){
        return toAjax(userService.resetUserPwd(TerminalEnum.BACKEND,oldPassword,newPassword));
    }
}
